import excel "......") firstrow
desc
destring, replace
desc

desc weight_full 
destring weight_full, replace
encode  weight_full, gen (weight_full1)
drop weight_full
rename weight_full1 weight_full

gen Newsmore =.
replace Newsmore =1 if NewsOnTV >=5
replace Newsmore = 0 if NewsOnTV<5


//Descriptive Stats:
* IVs:
sum InterestCampaign NewsOnTV DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative GOP patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism

* Summary Stats to Word
outreg2 using summarystats.doc, replace sum(log) keep(InterestCampaign NewsOnTV DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative GOP patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism)
* Summary Stats to Excel
outreg2 using summarystats, replace sum(log) keep(InterestCampaign NewsOnTV DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative GOP patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism) excel

*DVs:
** Policy toward unauthorized immigrants 
tabulate policy_unauthorized_immigrants 

* Pie Chart
graph pie [pweight = weight_full], over(policy_unauthorized_immigrants) cw plabel(_all percent, format(%4.2g)) title(Government Policy Towards Illegal Immigrants (2012) , size(medium) color(red)) legend(on stack position(5))

* Pie Chart by Republicans
graph pie [pweight = weight_full], over(policy_unauthorized_immigrants) cw plabel(_all percent, format(%4.2g)) by(, title(Government Policy Towards Illegal Immigrants by Republicans 2012, size(medium) color(red))) by(, legend(on position(5))) legend(stack) by(GOP, total)


** Policy toward Dreamers
tab citizenship_illegal_immigrants

* Pie Chart
graph pie [pweight = weight_full], over(citizenship_illegal) cw plabel(_all percent, format(%4.2g)) title(Opinion on Proposal to Allow Citizenship to Dreamers (2012), size(medium) color(red)) legend(on stack position(5))

* Pie Chart by Republicans

graph pie [pweight = weight_full], over(citizenship_illegal_immigrants) cw plabel(_all percent, format(%4.2g)) by(, title(Opinion on Proposal to Allow Citizenship to Dreamers by Republicans 2012, size(medium) color(red))) by(, legend(on position(5))) legend(stack) by(GOP, total)

** Feeling Thermo Illegal Immigrants
sum ftcasi_illegal
by GOP, sort : summarize ftcasi_illegal

histogram ftcasi_illegal, percent normal ytitle(Percentage) xtitle(Feeling Thermometer) title(Histogram of Feeling Thermometer Illegal Immigrants 2012, size(medium) color(red))



// Normalization all the independent variables to 0‐1
sum InterestCampaign NewsOnTV DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative GOP patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism

recode InterestCampaign (1=0) (2=.5) (3=1)
replace NewsOnTV= NewsOnTV/7 
replace DiscussPolitics = DiscussPolitics/7

recode FinancialLast (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode FinancialNext (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode NationalEconomyLast (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode NationalEconomyNext (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode WorryFinancialSituation (5=1) (4=.75) (3=.5) (2=.25) (1=0)

recode patriot_flag (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode patriot_amident (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode patriot_love (5=1) (4=.75) (3=.5) (2=.25) (1=0)
recode Relig_Churchoft (5=1) (4=.75) (3=.5) (2=.25) (1=0)

replace ethnocen = (ethnocent +100) / 200
replace Age = (Age - 19)/72


sum InterestCampaign NewsOnTV DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext WorryFinancialSituation patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft ethnocentricism


// Ordered Logistic Regression Immigration Policy (Pre-Election)
svyset [pweight=weight_full], strata(strata_full) psu(psu_full)

svy: ologit policy_unauthorized_immigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome  patriot_flag patriot_love patriot_amident ethnocentricism Conservative GOP ReligImportant Relig_Churchoft Bornagn InterestCampaign NewsOnTV DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income 

outreg2 using regression_results_2012, replace excel dec(2)

// Ordered/Logistic Regression Citizenship to Dreamers 
svy: ologit citizenship_illegal_immigrants FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome  patriot_flag patriot_love patriot_amident ethnocentricism Conservative GOP ReligImportant Relig_Churchoft Bornagn InterestCampaign NewsOnTV DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income

outreg2 using regression_results_2012, append excel dec(2)


* Making Citizensip to dreamers binary for 2016 comparison
tab citizenship_illegal_immigrants
gen citizenship_Dreamers = .
replace citizenship_Dreamers = 1 if  citizenship_illegal_immigrants== 2| citizenship_illegal_immigrants== 3
replace citizenship_Dreamers = 0 if citizenship_illegal_immigrants== 1
tab citizenship_Dreamers


svy: logit citizenship_Dreamers FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome  patriot_flag patriot_love patriot_amident ethnocentricism Conservative GOP ReligImportant Relig_Churchoft Bornagn InterestCampaign NewsOnTV DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income

outreg2 using regression_results_2012, append excel dec(2)


//Regression Feeling Thermo Illegal Immigrants
svy: reg ftcasi_illegal FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome  patriot_flag patriot_love patriot_amident ethnocentricism Conservative GOP ReligImportant Relig_Churchoft Bornagn InterestCampaign NewsOnTV DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income

outreg2 using regression_results_2012, append excel dec(2)


***INTERACTION


** DV: Policy toward unauthorized immigrants: Interaction terms
*Rally##GOP
svyset [pweight=weight_full], strata(strata_full) psu(psu_full)
svy: ologit policy_unauthorized_immigrants InterestCampaign NewsOnTV DiscussPolitics Rally##GOP FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism, level (84)
margins Rally , at(GOP=(0 1)) level (84)
marginsplot
margins Rally , at(GOP=1) level (84)
marginsplot

*InterestCampaign##GOP
recode InterestCampaign (0=1) (.5=2) (1=3)
tab InterestCampaign
svyset [pweight=weight_full], strata(strata_full) psu(psu_full)
svy: ologit policy_unauthorized_immigrants InterestCampaign##GOP NewsOnTV DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism, level (84)
margins InterestCampaign , at(GOP=(0 1)) level (84)
marginsplot
margins InterestCampaign , at(GOP=1) level (84)
marginsplot

*Newsmore##GOP
svyset [pweight=weight_full], strata(strata_full) psu(psu_full)
svy: ologit policy_unauthorized_immigrants InterestCampaign Newsmore##GOP DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism, level (84)
margins Newsmore , at(GOP=(0 1)) level (84)
marginsplot
margins Newsmore , at(GOP=1) level (84)
marginsplot


** DV: citizenship to dreamers: Interaction terms
*Newsmore##GOP
tab citizenship_Dreamers
svyset [pweight=weight_full], strata(strata_full) psu(psu_full)
svy: logit citizenship_Dreamers InterestCampaign Newsmore##GOP DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism, level (84)
margins Newsmore , at(GOP=(0 1)) level (84)
marginsplot
margins Newsmore , at(GOP=1) level (84)
marginsplot


*InterestCampaign##GOP
tab InterestCampaign
svy: logit citizenship_Dreamers InterestCampaign##GOP NewsOnTV  DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism, level (84)
margins InterestCampaign , at(GOP=(0 1)) level (84)
marginsplot
margins InterestCampaign , at(GOP=1) level (84)
marginsplot


*Rally##GOP
svyset [pweight=weight_full], strata(strata_full) psu(psu_full)
svy: logit citizenship_Dreamers InterestCampaign NewsOnTV  DiscussPolitics Rally##GOP FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism, level (84)
margins Rally , at(GOP=(0 1)) level (84)
marginsplot
margins Rally , at(GOP=1) level (84)
marginsplot

** DV: Feeling Thermo Illegal immigrants: Interaction terms
*Rally##GOP
svyset [pweight=weight_full], strata(strata_full) psu(psu_full)

svy: reg ftcasi_illegal InterestCampaign NewsOnTV DiscussPolitics Rally##GOP FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism, level (84)
margins Rally , at(GOP=(0 1)) level (84)
marginsplot
margins Rally , at(GOP=1) level (84)
marginsplot
 
*InterestCampaign##GOP

svyset [pweight=weight_full], strata(strata_full) psu(psu_full)
svy: reg ftcasi_illegal InterestCampaign##GOP NewsOnTV DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism, level (84)
margins InterestCampaign , at(GOP=(0 1)) level (84)
marginsplot
margins InterestCampaign , at(GOP=1) level (84)
marginsplot 
 
*Newsmore##GOP
svy: reg ftcasi_illegal InterestCampaign Newsmore##GOP DiscussPolitics Rally FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome Conservative patriot_flag patriot_love patriot_amident ReligImportant Relig_Churchoft Bornagn Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth income ethnocentricism, level (84)
margins Newsmore, at (GOP=(0 1)) level (84)
marginsplot
margins Newsmore, at (GOP=1) level (84)
marginsplot

***VOTE CHOICE / Feeling Thermo Romney
*presvote2012_x: 1-Obama, 2-Romney, 5-Other

//Normalization of Immigration Variables

sum policy_unauthorized_immigrants citizenship_Dreamers immigpo_level immigpo_jobs ftcasi_illegal

replace policy_unauthorized_immigrants = (policy_unauthorized_immigrants - 1)/3
replace immigpo_level = (immigpo_level - 1)/4
replace immigpo_jobs = (immigpo_jobs - 1)/3
replace ftcasi_illegal = (ftcasi_illegal)/100

sum policy_unauthorized_immigrants citizenship_Dreamers immigpo_level immigpo_jobs ftcasi_illegal

*Multinominal Logistic regression Vote Choice
svy: mlogit presvote2012_x policy_unauthorized_immigrants citizenship_Dreamers immigpo_level immigpo_jobs ftcasi_illegal, baseoutcome(2)

outreg2 using vote_choice_2012_results, replace excel dec(2)

ssc install coefplot, replace

coefplot, drop (cons) xline(0) omitted title ("Coeeficient Plots for Vote Choice 2012") xtitle ()

svy: mlogit presvote2012_x policy_unauthorized_immigrants citizenship_Dreamers immigpo_level immigpo_jobs ftcasi_illegal FinancialLast NationalEconomyLast Unemployed WorryFinancialSituation LowIncome patriot_amident ethnocentricism Conservative GOP Relig_Churchoft Bornagn InterestCampaign  Rally Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth, baseoutcome(2)

outreg2 using vote_choice_2012_results, append excel dec(2)

coefplot, drop (_cons) xline(0) omitted title ("Coeeficient Plots for Vote Choice 2012") xtitle ()

*Regression Feeling Thermo Romney
svy: reg ftpo_rpc policy_unauthorized_immigrants citizenship_Dreamers immigpo_level immigpo_jobs ftcasi_illegal

outreg2 using vote_choice_2012_results, append excel dec(2)


svy: reg ftpo_rpc policy_unauthorized_immigrants citizenship_Dreamers immigpo_level immigpo_jobs ftcasi_illegal FinancialLast NationalEconomyLast Unemployed WorryFinancialSituation LowIncome patriot_amident ethnocentricism Conservative GOP Relig_Churchoft Bornagn InterestCampaign  Rally Age CollegeEducated Hispanic White Parent Female HighIncome GrewSouth

coefplot, drop (_cons) xline(0) omitted title ("Coeeficient Plots for Feeling Thermo GOP candidate 2012", size (small)) xtitle ()


outreg2 using vote_choice_2012_results, append excel dec(2)


* 2012 model:
 
svy: logit vote4Romney policy_unauthorized_immigrants citizenship_Dreamers immigpo_level immigpo_jobs ftcasi_illegal FinancialLast FinancialNext NationalEconomyLast NationalEconomyNext Unemployed WorryFinancialSituation LowIncome  patriot_flag patriot_love patriot_amident ethnocentricism Conservative GOP ReligImportant Relig_Churchoft Bornagn InterestCampaign NewsOnTV DiscussPolitics Rally Age CollegeEducated Hispanic White Parent Female GrewSouth HighIncome
 
estimates store main_treat
 
coefplot main_treat, xline (0) level(95)






